package main

import (
	"fmt"
	"math"
	"math/cmplx"
)

/**
 * 2.2 内建变量类型
 * (1) bool, string
 * (2) (u)int, (u)int8,(u)int16,(u)int32,(u)int64, uintptr
 * (3) byte, rune
 * (4) float32, float64, complex64, complex128
 * 2.复数回顾
 * 复数：3 + 4i
 *
 * 3.强制类型转换
 * 类型转换是强制的
 * var a, b int = 3,4
 *
 *
 */
func main() {
	euler()
	triangle()
}

// 2.复数:验证欧拉公式
func euler() {
	//c := 3 + 4i
	//fmt.Println(cmplx.Abs(c))
	fmt.Println(cmplx.Pow(math.E, 1i*math.Pi) + 1)
	fmt.Println(cmplx.Exp(1i*math.Pi) + 1)
}

// 3.强制类型转换
func triangle() {
	var a, b int = 3, 4
	var c int
	c = int(math.Sqrt(float64(a*a + b*b)))
	fmt.Println(c)
}
